#define _CRT_SECURE_NO_WARNINGS
#include"zhan.h"
void SLinit(SL* p)
{
	assert(p);
	p->a = NULL;
	p->kong = p->top = 0;
}
void SLdestroy(SL* p)
{
	assert(p);
	free(p->a);
	p->a = NULL;
	p->kong = p->top = 0;
}
void SLpush(SL* p, leixing x)
{
	assert(p);
	if (p->kong == p->top)
	{
		int shu = p->top == 0 ? 4 : 2 * p->kong;
		leixing* A = (leixing*)realloc(p->a, sizeof(leixing) * shu);
		if (A == NULL)
		{
			perror("zhenqing A");
			return;
		}
		p->a = A;
		p->kong = shu;
	}
	p->a[p->top++] = x;
	
}
void SLpop(SL* p)
{
	assert(p);
	assert(p->top > 0);
	p->top--;
}
leixing SLTop(SL* p)
{
	assert(p);
	assert(p->top > 0);
	return p->a[p->top - 1];
}
int SLSize(SL* p)
{
	assert(p);
	 
	return p->top;
}
bool SLEmpty(SL* p)
{
	return p->top == 0;
}